package com.niiwoo.civet.trade.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 天秤变量计算(十二项风险规则)标的来源枚举
 * (该枚举暂时适用于1.天秤变量计算结果查询/天秤变量计算回调接口/天秤变量计算通知接口对应的fromSource字段的枚举值)
 *
 * @author daizhiyue
 * @date 2018-2-10
 */
@AllArgsConstructor
@Getter
public enum TCRiskRuleFromSourceEnum {
    SPEED_LOAN("1", "极速借"),
    R360("2", "融360"),
    CARD_NIU("3", "卡牛");

    private String value;
    private String desc;

    /**
     * 通过ProjectFromSourceEnum映射对应的TCRiskRuleFromSourceEnum
     *
     * @param projectFromSourceEnum
     * @return
     */
    public static String getTCRiskRuleFromSourceByProjectFromSource(ProjectFromSourceEnum projectFromSourceEnum) {
        TCRiskRuleFromSourceEnum tcRiskRuleFromSourceEnum;
        if (projectFromSourceEnum == null) {
            return TCRiskRuleFromSourceEnum.SPEED_LOAN.value;
        }
        switch (projectFromSourceEnum) {
            case APP:
                tcRiskRuleFromSourceEnum = TCRiskRuleFromSourceEnum.SPEED_LOAN;
                break;
            case H5_ACTIVITY:
                tcRiskRuleFromSourceEnum = TCRiskRuleFromSourceEnum.SPEED_LOAN;
                break;
            case H5_SPEED_LOAN:
                tcRiskRuleFromSourceEnum = TCRiskRuleFromSourceEnum.SPEED_LOAN;
                break;
            case R360:
                tcRiskRuleFromSourceEnum = TCRiskRuleFromSourceEnum.R360;
                break;
            case CARD_NIU:
                tcRiskRuleFromSourceEnum = TCRiskRuleFromSourceEnum.CARD_NIU;
                break;

            default:
                tcRiskRuleFromSourceEnum = TCRiskRuleFromSourceEnum.SPEED_LOAN;
                break;
        }
        return tcRiskRuleFromSourceEnum.getValue();
    }

}
